package com.omg.persistence.dao.lifepoint.sqlmapdao;

import java.util.List;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.omg.persistence.dao.lifepoint.entity.LPMessage;
import com.omg.persistence.dao.lifepoint.iface.LPMessageDao;

/**
 * 
 * @author roger
 * 
 */
public class LPMessageSqlMapDao extends SqlMapDaoTemplate implements
		LPMessageDao {

	public LPMessageSqlMapDao(DaoManager daoManager) {
		super(daoManager);
	}

	@Override
	public int addLPMessage(LPMessage lpMessage) {
		try {
			this.insert("addLPMessage", lpMessage);
			return 0;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}

	@Override
	public LPMessage getLPMessage(String messageid) {
		return (LPMessage) this.queryForObject("getLPMessage", messageid);
	}

	@Override
	public int delLPMessage(String messageid) {
		try {
			this.delete("delLPMessage", messageid);
			return 0;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}

	@Override
	public List<LPMessage> getLPMessageByUserid(String userid) {
		return this.queryForList("getLPMessageByUserid", userid);
	}

}
